#!/bin/bash
####################################################################
# Prey Geo Module - by Tomas Pollak (bootlog.org)
# URL: http://preyproject.com
# License: GPLv3
####################################################################

log ' -- Trying to get list of nearby Wifi access points...'
get_wifi_access_points

showcoordinates=`which showcoordinates`

if [[ -n "$wifi_points" || -n "$showcoordinates" ]]; then

	log " -- Got it! Now lets try to get a location fix..."
	get_current_location
	parse_location_response

	log " ####### $current_location_json ####### "
	local parsed_lat=`echo $current_lat | sed 's/[^0-9]//g'`

	if [ -n "$parsed_lat" ]; then

		add_trace 'lat' $current_lat
		add_trace 'lng' $current_lng
		add_trace 'accuracy' $spot_accuracy
		# add_trace 'address' "$current_address"
		# add_trace 'full' "$current_location_json"

	else

		log " !! Couldn't grab lat/lng coordinates. The geocoder service may be down."

	fi

else
	log " !! Couldn't get any Wifi information. Does this computer have Wifi capabilities?"
fi
